﻿function getURLParameter(name) {
    //alert(name.toUpperCase() + '-' + location.search.toUpperCase());
    return decodeURI(
                (RegExp(name.toUpperCase() + '=' + '(.+?)(&|$)').exec(location.search.toUpperCase()) || [, null])[1]
                );
}
$(document).ready(function () {
    var showBar = $.cookie('showBar');
    if (showBar == 'open') {
        $('#list_soli').show();
        $('.content_bottom').css('padding-bottom', '125px');
        /*$('html, body').animate({ scrollTop: $('#main_web').height() }, 800);*/
    }
    else {
        $('#list_soli').hide();
        $('.content_bottom').css('padding-bottom', '40px');
    }

    var loc = location.pathname;
    var arrURL = loc.split('/');
    var PAGE = arrURL[arrURL.length - 1];
    $(".nav_top a[href='" + loc + "']").addClass('selected');


    $('#display_signin').click(function (event) {
        if ($('#signin_cotent').css('display') == 'none') {
            $('#signin_cotent').show();
            $('#text_alr').html("Đã có tài khoản?");
            $('#display_signin').html("Đăng nhập");
            event.stopPropagation();
            $(document).keyup(function (event) {// press Enter key to Submit form
                if (event.keyCode == 13) {
                    $("#btn_sigin").click();
                }
            });
        } else {
            $('#signin_cotent').hide();
            $('#text_alr').html("Đã có tài khoản?");
            $('#display_signin').html("Đăng nhập");
        }
    });
    $('#signin_cotent').click(function (event) {
        event.stopPropagation();
    });
    //    $('#signin_cotent').mouseleave(function () {
    //        $('#signin_cotent').hide();
    //        $('#text_alr').html("Already have Soli?");
    //        $('#display_signin').html("Sign In");
    //    });

    $('#btn_show_bar').mouseover(function () {
        if ($('#list_soli').css('display') == 'none') {
            $('#list_soli').show();
            $('.content_bottom').css('padding-bottom', '125px');
            $.cookie('showBar', 'open');
            /*$('html, body').animate({ scrollTop: $('#main_web').height() }, 800);*/
            
        }
        else {
            $('#list_soli').hide();
            $('.content_bottom').css('padding-bottom', '40px');
            $.cookie('showBar', 'close');
        }
    });
    //    $('#footer').mouseleave(function () {
    //        $('#list_soli').hide();
    //    });
    $('#navAccountLink').click(function (event) {
        $(this).addClass('openToggler');
        $('.navigation').show();
        event.stopPropagation();
        
    });
    $('.navSubmenu').click(function (event) {
        event.stopPropagation();
    });

    $(document).click(function () {
        if ($('#signin_cotent').css('display') != 'none') {
            $('#signin_cotent').hide();
            $('#text_alr').html("Already have Soli?");
            $('#display_signin').html("Sign In");
            
        }
        if ($('.navigation').css('display') != 'none') {
            $('.navigation').hide();
            $('#navAccountLink').removeClass('openToggler');
        }
        
    });

});
